import 'package:flutter/material.dart';
import 'package:fluttertz/pages/czjl/index.dart';
import 'package:fluttertz/pages/ljwifi/index.dart';


// fluttertz 页面
import 'package:fluttertz/pages/login/login.dart';
import 'package:fluttertz/pages/login/regist.dart';
import 'package:fluttertz/pages/login/xgma.dart';
import 'package:fluttertz/pages/toolbar/index.dart';
import 'package:fluttertz/pages/wtfk/index.dart';
import 'package:fluttertz/pages/cjwt/index.dart';
import 'package:fluttertz/pages/xzwifi/index.dart';
import 'package:fluttertz/pages/zhzx/index.dart';
import 'package:fluttertz/pages/jtinfo/index.dart';

class RouterZ {
  static final _routes = {
    /// TODO: 从非toolbar页面跳转到toolbar页面的入场动画不一致
    // 从非toolbar页面（子页面）跳转到toolbar页面（主页）实现：
    // pushName到对应的路由，因为Toolbar是单例模式，所以只会创建一个
    // pushName之后，在ToolBar，initState中获取当前的路由，实现切换页面
    '/login': (BuildContext context, {Object args}) => Login(),
    '/home': (BuildContext context, {Object args}) => Toolbar(),
    '/addjt': (BuildContext context, {Object args}) => Toolbar(
          arguments: args,
        ),
    '/mine': (BuildContext context, {Object args}) => Toolbar(),
    '/wtfk': (BuildContext context, {Object args}) => Wtfk(),
    '/cjwt': (BuildContext context, {Object args}) => Cjwt(),
    '/czjl': (BuildContext context, {Object args}) => Czjl(),
    '/zhzx': (BuildContext context, {Object args}) => Zhzx(),
    '/xgma': (BuildContext context, {Object args}) => Xgma(),
    '/jtinfo': (BuildContext context, {Object args}) => Jtinfo(),
    '/regist': (BuildContext context, {Object args}) => Regist(),
    '/xzwifi': (BuildContext context, {Object args}) => Xzwifi(),
    '/ljwifi': (BuildContext context, {Object args}) => Ljwifi(),

  };

  static RouterZ _singleton;

  RouterZ._internal();

  factory RouterZ() {
    if (_singleton == null) {
      _singleton = RouterZ._internal();
    }

    return _singleton;
  }

  /// 监听route
  Route getRoutes(RouteSettings settings) {
    String routeName = settings.name;
    final Function builder = RouterZ._routes[routeName];

    print(settings);

    if (builder == null) {
      return null;
    } else {
      return MaterialPageRoute(
          settings: settings,
          builder: (BuildContext context) =>
              builder(context, args: settings.arguments));
    }
  }
}
